<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <title>管理后台 - php RESTful</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <header class="main-header">
        <!-- Logo -->
        <a href="#" class="logo">
            <!-- mini logo for sidebar mini 50x50 pixels -->
            <span class="logo-mini">REST</span>
            <!-- logo for regular state and mobile devices -->
            <span class="logo-lg">PHP-<b>RESTful</b></span>
        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>

            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                     
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img src="/dist/img/coffee.jpg" class="user-image" alt="User Image">
                            <span class="hidden-xs"> </span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- User image -->
                            <li class="user-header">
                                <img src="/dist/img/coffee.jpg" class="img-circle" alt="User Image">

                                <p>
                                     
                                    <small> </small>
                                </p>
                            </li>
                            </li>
                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="#" class="btn btn-default btn-flat">个人中心</a>
                                </div>
                                <div class="pull-right">
                                    <button data-href="/adminRest/v1/JwtToken" data-method="DELETE"
                                            class="btn btn-default btn-flat ajax-button">登 出
                                    </button>
                                </div>
                            </li>
                        </ul>
                    </li>
                    <!-- Control Sidebar Toggle Button -->
                    <li>
                        <a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
                    </li>
                </ul>
            </div>
        </nav>
    </header>


    <!-- Left side column. contains the logo and sidebar -->
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- Sidebar user panel -->
            <div class="user-panel">
                <div class="pull-left image">
                    <img src="/dist/img/coffee.jpg" class="img-circle" alt="User Image">
                </div>
                <div class="pull-left info">
                    <p> </p>
                    <a href="#"><i class="fa fa-circle text-success"></i> Online</a>
                </div>
            </div>
            <!-- search form -->
            <!-- <form action="#" method="get" class="sidebar-form">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" placeholder="Search...">
                    <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
                </div>
            </form> -->
            <!-- /.search form -->
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu" data-widget="tree">
                <li class="header" id="sidebar-menu">菜单列表</li>

                <li class="header">直达标签</li>
                <li><a href="#"><i class="fa fa-circle-o text-red"></i> <span>Important</span></a></li>
                <li><a href="#"><i class="fa fa-circle-o text-yellow"></i> <span>Warning</span></a></li>
                <li><a href="#"><i class="fa fa-circle-o text-aqua"></i> <span>Information</span></a></li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>


    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <!--<section class="content-header">-->
        <!--<h1>-->
        <!--Dashboard-->
        <!--<small>Control panel</small>-->
        <!--</h1>-->
        <!--<ol class="breadcrumb">-->
        <!--<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>-->
        <!--<li class="active">Dashboard</li>-->
        <!--</ol>-->
        <!--</section>-->

        <!-- Main content -->
        <section class="content">
            <!-- Small boxes (Stat box) -->
            <div class="row">

            </div>
            <!-- /.row -->

            <!-- /.row -->
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title">&nbsp;菜单树</h3>

                            <div class="card-tools row">
                                <div class="col-xs-8">
                                    &nbsp;<a class="btn btn-primary btn-sm " href="/admin/menu/add.html">添加</a>
                                </div>
                            </div>

                        </div>
                        <!-- /.card-header -->
                        <div class="card-body table-responsive p-0">
                            <table class="table table-hover text-nowrap">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>标题</th>
                                    <th>路由</th>
                                    <th>图标</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="table-body">

                                </tbody>
                            </table>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
            </div>

            <!-- Main row -->
            <div class="row" id="pagination">
            </div>
            <!-- /.row (main row) -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
     

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Create the tabs -->
        <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
            <li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
            <!-- <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li> -->
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <!-- Home tab content -->
            <div class="tab-pane" id="control-sidebar-home-tab">

            </div>
        </div>
    </aside>

</div>
<!-- ./wrapper -->

<script src="/bower_components/jquery/dist/jquery.js"></script>

<!-- Bootstrap 3.3.7 -->
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>

<!-- AdminLTE App -->
<script src="/dist/js/adminlte.min.js"></script>

<!-- AdminLTE for demo purposes -->
<script src="/dist/js/demo.js"></script>

<script src="/plugins/jquery-tmpl/jquery.tmpl.js"></script>

<link rel="stylesheet" href="/plugins/pagination/dist/pagination.css">
<script src="/plugins/pagination/dist/pagination.js"></script>

<script id="sidebar-level-1" type="text/x-jquery-tmpl">
{{if $data._child}}
<li class="treeview">
    {{if $data.pathname == '' || $data.pathname == '#' || $data.pathname == null || $data.pathname== undefined}}
    <a href="#">
    {{else}}
    <a href="${pathname}">
    {{/if}}
        <i class="${iconfont} fa"></i> <span>${title}</span>
        <span class="pull-right-container">
            <i class="fa fa-angle-left pull-right"></i>
        </span>
    </a>
    <ul class="treeview-menu">
        {{tmpl($data._child) '#sidebar-level-1'}}
    </ul>
</li>
{{else}}
<li>
    {{if $data.pathname == '' || $data.pathname == '#' || $data.pathname == null || $data.pathname== undefined}}
    <a href="#">
    {{else}}
    <a href="${pathname}">
    {{/if}}
        <i class="fa ${iconfont}"></i>
        <span>${title}</span>
    </a>
</li>
{{/if}}

</script>

<script id="table-list" type="text/x-jquery-tmpl">
<tr>
    <td>${menu_id}</td>
    <td>${title_show}</td>
    <td>${route}</td>
    <td>${iconfont}</td>
    <td>{{html operation}}</td>
</tr>

</script>
<style>
    #table-body>tr>td{
        padding-bottom: 0;
    }
</style>
<script>
    let sideBarPath = '/admin/menu/list.html';
</script>
<script src="/dist/js/admin.common.js"></script>
<script>
    initSideBar();
    function initMenuSelect() {
        let sourceUrl = window.location.origin + "/adminRest/v1/menu";
        $.ajax({
            url: window.location.origin + "/adminRest/v1/MenuTree",
            method: 'GET',
            async: false,
            success: function (res) {
                console.log(res);
                for (let i = 0; i < res.data.length; i++) {
                    let buttons = '';
                    buttons += genButtonEdit(window.location.origin + '/admin/menu/edit.html#' + res.data[i].menu_id);
                    buttons += genButtonDel(sourceUrl + '/' + res.data[i].menu_id, 'DELETE');
                    res.data[i].operation = buttons;
                }
                $('#table-list').tmpl(res.data).appendTo('#table-body');
            }
        })
    }
    initMenuSelect();
</script>

<script>
    $(function () {
    })
</script>

</body>
</html>
